﻿using AutoMapper;
using XLZF.MicroServices.Models;
using XLZF.MicroServices.ViewModels;

namespace XLZF.MicroServices.Common.Mapping;

public class AutoMapperConfigs : Profile
{
    /// <summary>
    /// 可以配置互转的类，数据实体转视图实体
    /// </summary>
    public AutoMapperConfigs()
    {
        CreateMap<Clothing_Class_Dict, ClothingDictViewModel>()
            .ForMember(dest => dest.ObjID, option => option.MapFrom(op => op.ID))
            .ForMember(dest => dest.ObjName, option => option.MapFrom(op => op.ClassName));

        CreateMap<Page<Clothing_Class_Dict>, Page<ClothingDictViewModel>>();

        CreateMap<Clothing_Class_Detail, ClothingDetailViewModel>()
            .ForMember(dest => dest.ObjID, option => option.MapFrom(op => op.ID))
            .ForMember(dest => dest.ObjName, option => option.MapFrom(op => op.DetailName))
            .ForMember(dest => dest.ObjPID, option => option.MapFrom(op => op.PID))
            .ForMember(dest => dest.ClassName, option => option.MapFrom(op => op.Clothing_Class_Dict.ClassName));

        CreateMap<Page<Clothing_Class_Detail>, Page<ClothingDetailViewModel>>();
    }
}
